package com.bw.module_service.adapter


import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bw.module_service.R
import com.bw.module_service.model.InspectionModel
import com.bw.module_service.model.InspectionModelItem

class TaskPollingAdapter(private val polling: List<InspectionModelItem>): RecyclerView.Adapter<TaskPollingAdapter.PollingViewHolder>() {

    class PollingViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val ip: TextView = itemView.findViewById(R.id.ip)
        val sip: TextView = itemView.findViewById(R.id.sip)
        val state: TextView = itemView.findViewById(R.id.state)
    }

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int,
    ): PollingViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.taskpollingitem, parent, false)
        return PollingViewHolder(view)
    }

    override fun onBindViewHolder(
        holder: PollingViewHolder,
        position: Int,
    ) {
        val item=polling[position]
        holder.ip.text=item.pointLocation
        holder.sip.text=item.pointName
        if (item.patrolStandard.equals("123")){
            holder.state.text="已巡检"
        }else if (item.patrolStandard.equals("2")){
            holder.state.text="未巡检"
        }else if (item.patrolStandard.equals("1,2")){
            holder.state.text="巡检中"
        }else if (item.patrolStandard.equals("1")){
            holder.state.text="未巡检"
        }






    }

    override fun getItemCount(): Int {
        return  polling.size
    }
}